package com.xb.cloud.front.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xb.cloud.front.common.FrontSKUService;
import com.xb.cloud.gateway.client.ReturnUtils;
import com.xb.cloud.gateway.client.RtnInfo;
import com.xb.cloud.product.category.service.client.bo.SkuRequestBO;
import com.xb.cloud.product.service.client.SkuService;
import com.xb.cloud.service.client.ServiceReturnInfo;
import com.xb.cloud.service.client.ServiceReturnUtils;

@Service
public class FrontSKUServiceImpl implements FrontSKUService {
	@Autowired
	private SkuService skuService;
	
	@Override
	public RtnInfo getSKUListByFrontCategory(SkuRequestBO requestBO) {
		ServiceReturnInfo serviceReturnInfo = skuService.getSkuByFrontCategoryList(requestBO);
		if(ServiceReturnUtils.isSuccess(serviceReturnInfo)) {
			return ReturnUtils.success(serviceReturnInfo.getData());
		}
		return null;
	}

	/**
	 * 根据店铺的编号 & 店铺内分组id查找sku列表
	 * 
	 */
	@Override
	public RtnInfo getSkuListByGroup(Long shopId, Long groupId, int pageNum, int pageSize, int sortType,
			int sortOrder) {
		ServiceReturnInfo returnInfo = skuService.getSkuListByGroup(shopId, groupId, pageNum, pageSize, sortType,
				sortOrder);
		if(ServiceReturnUtils.isSuccess(returnInfo)) {
			return ReturnUtils.success(returnInfo.getData());
		}else{
			return ReturnUtils.success(null);
		}
	}
	
	@Override
	public RtnInfo getSKUDetail(SkuRequestBO requestBO) {
		ServiceReturnInfo serviceReturnInfo = skuService.getSKUDetail(requestBO);
		if(ServiceReturnUtils.isSuccess(serviceReturnInfo)) {
			return ReturnUtils.success(serviceReturnInfo.getData());
		} else {
			//ReturnUtils.error(serviceReturnInfo.getData());
		}
		return null;
	}

	@Override
	public RtnInfo getSKUPrice(SkuRequestBO requestBO) {
		ServiceReturnInfo serviceReturnInfo = skuService.getSKUPrice(requestBO);
		if(ServiceReturnUtils.isSuccess(serviceReturnInfo)) {
			return ReturnUtils.success(serviceReturnInfo.getData());
		} else {
			//ReturnUtils.error(serviceReturnInfo.getData());
		}
		return null;
	}
}
